package com.focus.wecenter.web.controller.common;

import com.focus.wecenter.pojo.User;
import com.focus.wecenter.util.SysConstant;
import org.apache.log4j.Logger;

import javax.servlet.http.HttpSession;

/**
 * @description 
 * @author Lv Jing
 * @date 2017年8月18日
 */
public class BaseController {

	protected static final Logger log = Logger.getLogger(BaseController.class);
	
	protected User getSessionUser(HttpSession session) {
		return (User) session.getAttribute(SysConstant.CURRENT_LOGIN_USER);
	}
	
	protected void setSessionUser(HttpSession session, User user) {
		session.setAttribute(SysConstant.CURRENT_LOGIN_USER, user);
	}
	
	protected int getSessionUserID(HttpSession session) {
		User user = (User) session.getAttribute(SysConstant.CURRENT_LOGIN_USER);
		if (user == null) {
		    return -1;
        }
		return user.getId();
	}

	protected void removeSessionUser(HttpSession session) {
	    session.removeAttribute(SysConstant.CURRENT_LOGIN_USER);
    }
}
